package polymorphic;

class Animals{
    public String name;
    public Animals(String name){
        this.name=name;
        eat();
    }
    public void eat(){
        System.out.println(this.name+"吃饭 Animals");
    }
}
class Cat extends Animals{
    public int age;
    public Cat(){
        super("小猫咪");
    }
    @Override
    public void eat(){
        System.out.println(this.name+"吃饭 Cat");
    }
}
class Birds extends Animals{
    public String name="小鸟";
    public Birds(String name){

        super(name);
    }
    public void fly(){

        System.out.println(this.name+"飞起来了");
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Cat cat=new Cat();
    }
    public static void mai4n(String[] args) {
        Animals animals=new Cat();
        animals.eat();
    }
    public static void main3(String[] args) {
        Animals animals=new Cat();
        if(animals instanceof Birds){
            Birds birds=(Birds)animals;
            birds.fly();
        }

    }
    public static Animals func2(){
        Cat cat=new Cat();
        return cat;
    }
    public static void func(Animals animals){

    }
    public static void main2(String[] args) {
        Cat cat=new Cat();
        func(cat);
    }
    public static void main1(String[] args) {
        Animals animals=new Cat();
    }
}
